package com.yhq.spring.web.controller;

import com.yhq.spring.web.service.CalculateService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author hqyin
 * @date 2024/9/20 10:35 AM
 */

@RestController
@Slf4j
@Tag(name = "测试接口")
public class TestController {
    @Autowired
    private CalculateService calculateService;

    @Operation(summary = "订单详情")
    @PostMapping("/ticketDetail")
    public PlainResult ticketDetail(@RequestBody TicketDetail ticketDetail) throws InterruptedException {
        String key =  ticketDetail.getTicketId().intern();
        synchronized (key){
            Thread.sleep(10000);
            log.info("收到信息：{}",ticketDetail);
        }
        return PlainResult.success();
    }

    @PostMapping("/ticketBoard")
    public PlainResult ticketDetail(@RequestBody String data) {
        log.info("收到信息：{}",data);
        log.info("结果",calculateService.add());

        return PlainResult.success();
    }
}
